package com.tianlan.blog.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.tianlan.blog.dao.EmployeeAttendanceDao;
import com.tianlan.blog.dto.QueryEmployeeAttendance;
import com.tianlan.blog.entity.EmployeeAttendance;
import com.tianlan.blog.service.EmployeeAttendanceService;
import com.tianlan.common.page.MyPage;

@Service
public class EmployeeAttendanceServiceImpl implements EmployeeAttendanceService {

	@Autowired
	private EmployeeAttendanceDao employeeAttendanceDao;
	
	@Override
	public List<EmployeeAttendance> selectEmployeeAttendanceList(QueryEmployeeAttendance employee,MyPage<EmployeeAttendance> page) {	
		return employeeAttendanceDao.selectEmployeeAttendanceList(employee,page);
	}
	
	@Override
	public int selectEmployeeAttendanceCount(QueryEmployeeAttendance employee) {
		return employeeAttendanceDao.selectEmployeeAttendanceCount(employee);
	}

	@Override
	public List<EmployeeAttendance> findAllByDelFlag() {
		return employeeAttendanceDao.findAllByDelFlag("0");
	}
	
	@Transactional
	@Modifying
	@Override
	public List<EmployeeAttendance> insertEmployeeAttendanceList(List<EmployeeAttendance> employeeList) {
		return employeeAttendanceDao.saveAll(employeeList);
	}

	@Override
	public boolean updateImg(String imgUrl, Integer id) {
		int isUpdateImg = employeeAttendanceDao.updateImg(imgUrl, id);
		return isUpdateImg != 0;
	}

	
}
